<template>
  <div class="default-page">
    <div class="page-header">
      <div class="header-content">
        <h1 class="page-title">{{ pageTitle }}</h1>
        <p class="page-description">{{ pageDescription }}</p>
      </div>
      <div class="header-actions">
        <el-button type="primary" :icon="Plus" @click="handleCreateComponent">
          创建组件
        </el-button>
      </div>
    </div>

    <div class="default-content">
      <div class="empty-state">
        <div class="empty-icon">
          <el-icon :size="64" color="hsl(215.4 16.3% 46.9%)">
            <Document />
          </el-icon>
        </div>
        <h3 class="empty-title">页面组件待开发</h3>
        <p class="empty-description">
          该页面组件尚未创建，请联系开发人员创建对应的Vue组件。
        </p>
        
        <div class="page-info">
          <div class="info-item">
            <span class="info-label">页面路径：</span>
            <code class="info-value">{{ $route.path }}</code>
          </div>
          <div class="info-item">
            <span class="info-label">菜单代码：</span>
            <code class="info-value">{{ $route.meta?.code || 'unknown' }}</code>
          </div>
          <div class="info-item">
            <span class="info-label">组件路径：</span>
            <code class="info-value">{{ componentPath }}</code>
          </div>
        </div>

        <div class="development-tips">
          <h4>开发提示：</h4>
          <ol>
            <li>在 <code>src/views/admin/</code> 目录下创建对应的Vue组件</li>
            <li>在 <code>src/utils/dynamicRoutes.js</code> 中添加组件映射</li>
            <li>重新启动开发服务器以加载新组件</li>
          </ol>
        </div>

        <div class="quick-actions">
          <el-button @click="goBack" :icon="ArrowLeft">返回上一页</el-button>
          <el-button @click="goHome" :icon="House">回到首页</el-button>
          <el-button @click="refreshPage" :icon="Refresh">刷新页面</el-button>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { computed } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { ElMessage } from 'element-plus'
import {
  Plus, Document, ArrowLeft, House, Refresh
} from '@element-plus/icons-vue'

const route = useRoute()
const router = useRouter()

// 计算页面标题
const pageTitle = computed(() => {
  return route.meta?.title || '未知页面'
})

// 计算页面描述
const pageDescription = computed(() => {
  return `${pageTitle.value}功能正在开发中，敬请期待...`
})

// 计算组件路径
const componentPath = computed(() => {
  const path = route.path
  if (path.startsWith('/admin/')) {
    return `src/views/admin${path.substring(6)}.vue`
  }
  return `src/views${path}.vue`
})

// 返回上一页
const goBack = () => {
  router.back()
}

// 回到首页
const goHome = () => {
  router.push('/admin/dashboard')
}

// 刷新页面
const refreshPage = () => {
  window.location.reload()
}

// 创建组件（开发功能）
const handleCreateComponent = () => {
  ElMessage.info('该功能需要开发人员手动创建组件文件')
}
</script>

<style scoped>
/* shadcn风格的默认页面样式 */
.default-page {
  padding: 0;
  background: transparent;
  min-height: 100%;
}

/* 页面标题 */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 32px;
}

.header-content h1.page-title {
  font-size: 24px;
  font-weight: 700;
  color: hsl(222.2 84% 4.9%);
  margin: 0 0 4px 0;
  line-height: 1.2;
}

.header-content p.page-description {
  color: hsl(215.4 16.3% 46.9%);
  font-size: 14px;
  margin: 0;
}

.header-actions .el-button {
  background: hsl(221.2 83.2% 53.3%);
  border: 1px solid hsl(221.2 83.2% 53.3%);
  color: hsl(210 40% 98%);
  font-weight: 500;
  border-radius: 6px;
}

/* 默认内容 */
.default-content {
  background: hsl(0 0% 100%);
  border: 1px solid hsl(214.3 31.8% 91.4%);
  border-radius: 8px;
  padding: 48px 24px;
}

.empty-state {
  text-align: center;
  max-width: 600px;
  margin: 0 auto;
}

.empty-icon {
  margin-bottom: 24px;
}

.empty-title {
  font-size: 20px;
  font-weight: 600;
  color: hsl(222.2 84% 4.9%);
  margin: 0 0 12px 0;
}

.empty-description {
  color: hsl(215.4 16.3% 46.9%);
  font-size: 16px;
  margin: 0 0 32px 0;
  line-height: 1.5;
}

/* 页面信息 */
.page-info {
  background: hsl(210 40% 96%);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 32px;
  text-align: left;
}

.info-item {
  display: flex;
  align-items: center;
  margin-bottom: 8px;
}

.info-item:last-child {
  margin-bottom: 0;
}

.info-label {
  font-weight: 500;
  color: hsl(222.2 84% 4.9%);
  min-width: 100px;
}

.info-value {
  background: hsl(0 0% 100%);
  border: 1px solid hsl(214.3 31.8% 91.4%);
  border-radius: 4px;
  padding: 4px 8px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  color: hsl(221.2 83.2% 53.3%);
}

/* 开发提示 */
.development-tips {
  background: hsl(210 40% 96%);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 32px;
  text-align: left;
}

.development-tips h4 {
  font-size: 16px;
  font-weight: 600;
  color: hsl(222.2 84% 4.9%);
  margin: 0 0 12px 0;
}

.development-tips ol {
  margin: 0;
  padding-left: 20px;
  color: hsl(215.4 16.3% 46.9%);
}

.development-tips li {
  margin-bottom: 8px;
  line-height: 1.5;
}

.development-tips code {
  background: hsl(0 0% 100%);
  border: 1px solid hsl(214.3 31.8% 91.4%);
  border-radius: 4px;
  padding: 2px 6px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  color: hsl(221.2 83.2% 53.3%);
}

/* 快捷操作 */
.quick-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.quick-actions .el-button {
  border-radius: 6px;
  font-weight: 500;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }
  
  .default-content {
    padding: 32px 16px;
  }
  
  .quick-actions {
    flex-direction: column;
    align-items: center;
  }
  
  .quick-actions .el-button {
    width: 200px;
  }
}
</style>